/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package alcatelparser.tags;

import alcatelparser.modules.AlgoUtil;
import alcatelparser.modules.BuilderFactory;
import alcatelparser.modules.Env;
import alcatelparser.modules.I;

/**
 *
 * @author geniuz
 */
public class BearerServiceTag extends DefaultParserTag
{

    public BearerServiceTag()
    {
    }

    public void parseTag(int ai[], int i)
    {
        _array = ai;
        _length = AlgoUtil.getLength(ai, i + 1);
        _startParsePosition = i;
        setStandartLength(ai, i);
        /*
        if(Env.getEnv().isFullForm())
        {
            BuilderFactory.getBuilder().writeTagContent(3, 0, getTagPropertiesValue(getResultTagName()), getTagIdentifyContent(i, i + 1));
            parseCapatibility(i);
            parseMultiplier(i);
        } else
        {
            if(isTagChecked(I.I(1625)))
                parseCapatibility(i);
            if(isTagChecked(I.I(1662)))
                parseMultiplier(i);
        }*/
    }

    private void parseMultiplier(int i)
    {
        if(_length - 3 > 0)
        {
            String s = getTagPropertiesValue(getCapatiblityMultiplierSubTagName());
            int j = 0;
            String s2 = "";
            for(; j < _length - 3; j++)
                s2 = (new StringBuilder()).append(s2).append(toHex(_array[i + 3 + j])).toString();

            if(Env.getEnv().isFullForm())
                BuilderFactory.getBuilder().writeTagContent(4, 2, s, s2);
            else
            if(isTagChecked(getCapatiblityMultiplierSubTagID()))
            {
                String s1 = getReducedTagPropertiesValue(getCapatiblityMultiplierSubTagName());
                if(Env.getEnv().isFieldsDecoding())
                    BuilderFactory.getBuilder().writeTagContent(1, 0, s1, s2);
                else
                    BuilderFactory.getBuilder().writeTagContent(1, 0, s1, s2);
            }
        }
    }

    private void parseCapatibility(int i)
    {
        String s = getTagIdentifyContent(i + 2, i + 3);
        String s1 = getTagPropertiesValue(getCapatiblitySubTagName());
        int j = _array[i + 4];
        String s3 = getTagPropertiesValue((new StringBuilder()).append(I.I(6956)).append(j).toString());
        String s4 = (new StringBuilder()).append(s).append(toHex(j)).append(I.I(5425)).append(s3).toString();
        if(Env.getEnv().isFullForm())
            BuilderFactory.getBuilder().writeTagContent(4, 0, s1, s4);
        else
        if(isTagChecked(getCapatiblitySubTagID()))
        {
            String s2 = getReducedTagPropertiesValue(getCapatiblitySubTagName());
            if(Env.getEnv().isFieldsDecoding())
                BuilderFactory.getBuilder().writeTagContent(1, 0, s2, s3);
            else
                BuilderFactory.getBuilder().writeTagContent(1, 0, s2, toHex(j));
        }
    }

    public String getParseIdentityTag()
    {
        return I.I(6953);
    }

    public boolean isTagRequired()
    {
        return true;
    }

    public final String getResultTagName()
    {
        if(_resultTagName == null)
            return I.I(6934);
        else
            return _resultTagName;
    }

    public final void setResultTagName(String s)
    {
        _resultTagName = s;
    }

    public final String getCapatiblitySubTagID()
    {
        if(_resultTagName == null)
            return I.I(1625);
        else
            return I.I(2646);
    }

    public final String getCapatiblityMultiplierSubTagID()
    {
        if(_resultTagName == null)
            return I.I(1662);
        else
            return I.I(2702);
    }

    public final String getCapatiblitySubTagName()
    {
        if(_resultTagName == null)
            return I.I(1642);
        else
            return I.I(2671);
    }

    public final String getCapatiblityMultiplierSubTagName()
    {
        if(_resultTagName == null)
            return I.I(1689);
        else
            return I.I(2737);
    }

    private String _resultTagName;
    private int _length;
}
